package com.tjetc.usermanage;

import com.tjetc.domian.Communitynotice;
import com.tjetc.proxy.ClientProxy;
import com.tjetc.service.NoticeService;

import java.util.List;
import java.util.Scanner;

public class NoticeView {
    private Scanner scanner = new Scanner(System.in);
    private NoticeService noticeService = ClientProxy.getProxyInstance(NoticeService.class);
    public void start() {
        while (true) {
            System.out.println("公告菜单");
            System.out.println("1.查询公告信息");
            System.out.println("0.返回上一级");
            int i = scanner.nextInt();
            switch (i){
                case 1:
                    select();
                    break;
                case 0:
                    return;
            }
        }
    }

    private void select() {
        System.out.println("查看公告");
        List<Communitynotice> communitynotices = noticeService.select();
        if (communitynotices == null){
            System.out.println("没有公告");
        }else{
            for (Communitynotice communitynotice : communitynotices) {
                System.out.println(communitynotice);
            }
        }

    }
}
